using Indiefreaks.Xna.Core;
using Indiefreaks.Xna.Physics;
using Indiefreaks.Xna.Rendering;
using Indiefreaks.Xna.Rendering.Gui;
using Indiefreaks.Xna.Sessions.Local;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Indiefreaks.AceOnSteroids
{
#if WINDOWS || XBOX360
    /// <summary>
    /// Boot class containing the game Main entry method required for Windows & Xbox 360
    /// </summary>
    public class Boot
    {
        public static void Main()
        {
            using (var application = new AceOnSteroidsApplication())
            {
                application.Run();
            }
        }
    }
#endif

    /// <summary>
    /// Our main game application class
    /// </summary>
    public class AceOnSteroidsApplication : Application
    {
        /// <summary>
        /// Creates a new instance of the game
        /// </summary>
        public AceOnSteroidsApplication() : base("Ace on Steroids", "Content")
        {
        }

        #region Overrides of Application

        /// <summary>
        /// This is where you preferably will initialize and add all the Managers you want to use for this game
        /// </summary>
        protected override void InitializeSunBurn()
        {
            // we add the local only SessionManager instance.
            SunBurn.AddManager(new LocalSessionManager(this));
            // we add the manager which handles the GUI for us.
            SunBurn.AddManager(new GuiManager(GraphicsDeviceManager));
            // we'll use IGF BEPUPhysics implementation to handle the game physics
            SunBurn.AddManager(new BEPUPhysicsManager(GraphicsDeviceManager));

            // Helper method found in Application class to create the Rendering Managers for you
            CreateRenderer(Renderers.Deferred);
        }

        /// <summary>
        /// Initialize the game
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // if not told to, the Indiefreaks Game Framework will work with GamePads as sole input system on Windows
            // If you want to allow Keyboard & Mouse controls, you'll need to activate the KeyboardAndMouseInput system and
            // eventually setup the virtual gamepad mapping. Here's how:

            // since the InputManager isn't yet initialized, we only can retrieve PlayerInput instances using the physical playerindex input using the following method:
            var playerInputOne = Input.GetPlayerInput(PlayerIndex.One);

            // to activate the Keyboard & Mouse input system
            playerInputOne.UseKeyboardMouseInput = true;

            // if you want to change the virtual gamepad mapping:
            playerInputOne.VirtualGamePadMapping.LeftStickLeft = Keys.Left;
            playerInputOne.VirtualGamePadMapping.LeftStickForward = Keys.Up;
            playerInputOne.VirtualGamePadMapping.LeftStickRight = Keys.Right;
            playerInputOne.VirtualGamePadMapping.LeftStickBackward = Keys.Down;

            // We first start by loading our IntroductionGameState
            LoadGameState(new IntroductionGameState(this));
        }

        #endregion
    }
}